package lily.phs.urh;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import lily.phs.database.Constants;
import lily.phs.object.HereTipa;
import lily.phs.object.IDCard;
import lily.phs.object.PersonInfo;
import lily.phs.object.PersonInfoLog;
import lily.phs.urh.R;
import lily.ui.control.MyPopupWindow;


import android.app.DatePickerDialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;

import android.view.WindowManager.LayoutParams;
//import android.widget.CheckBox;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;


public class BuilderView_1 extends LinearLayout implements OnClickListener,Constants, OnFocusChangeListener{
	
	private View view;
	MyPopupWindow mPopupWindow;
	
	private Context myContext;
	
	private EditText et_name,et_id_card;
	private CheckBox cb_idcard_x;
	private EditText et_address,et_household;
	private Spinner sp_address_team,sp_household_team;
	private EditText et_pein_phone;
	private EditText et_pein_work;
	private EditText et_pein_contact_name;
	private EditText et_pein_contact_phone;
	private RadioGroup rg_pein_permatent_type;
	private RadioButton rb_pein_register,rb_pein_unregister;
	private RadioGroup rg_pein_nation;
	private RadioButton rb_pein_han,rb_pein_minority;
	private EditText et_pein_minority;
	private RadioGroup rg_pein_blood_type;
	private RadioButton rb_pein_blood_Atype, rb_pein_blood_Btype, rb_pein_blood_Otype,
						rb_pein_blood_ABtype, rb_pein_blood_nonetype;
	private RadioGroup rg_pein_rh_negative;
	private RadioButton rb_pein_rh_negative_y,rb_pein_rh_negative_N,rb_pein_rh_negative_none;
	private RadioGroup rg_pein_culture_stdd;
	private RadioButton rb_pein_illiteracy,rb_pein_grade,rb_pein_junior,rb_pein_senior,
						rb_pein_college,rb_pein_noneculture;
	private RadioGroup rg_pein_occupation;
	private RadioButton rb_pein_state_organs,rb_pein_worker,rb_pein_vawirrmqyyoy,
						rb_pein_commercial,rb_pein_farmer,rb_pein_production,rb_pein_soldier,
						rb_pein_occ_other;
	private RadioGroup rg_pein_marriage;
	private RadioButton rb_pein_unmarriage,rb_pein_marriaged,rb_pein_sanghun,rb_pein_divorce,rb_pein_none_marriage;
	private CheckBox cb_pein_city_worker,cb_pein_country_resident,cb_pein_newvillage,cb_pein_poor,
					 cb_pein_trade_hos_insurance,
					 cb_pein_allpubexpense,cb_pein_allpriexpense,cb_pein_hos_cost_other;
	private EditText et_pein_hos_cost_other;
	private CheckBox cb_pein_drug_none,cb_pein_drug_penicillin,cb_pein_drug_sulfanilamide,
					 cb_pein_drug_streptomycin,cb_pein_drug_other;
	private EditText et_pein_drug_other;
	private CheckBox cb_pein_exposure_his_none,cb_pein_exposure_his_chemistry,
					 cb_pein_exposure_his_poison,cb_pein_exposure_his_radial;
	private CheckBox cb_pein_disease_none,cb_pein_disease_hypertension,cb_pein_disease_diabetesmellitus,
					 cb_pein_disease_coronary,cb_pein_disease_cancer,cb_pein_disease_lung,cb_pein_disease_stroke,
					 cb_pein_disease_mental,cb_pein_disease_tuberculosis,
					 cb_pein_disease_hepatitis,cb_pein_disease_othercontagion,cb_pein_disease_occ,cb_pein_disease_other;
	private EditText et_pein_disease_cancer;
	private EditText et_pein_disease_occ;	
	private EditText et_pein_disease_other;
	private EditText et_pein_disease_year1;
	private EditText et_pein_disease_month1;
	private EditText et_pein_disease_year2;
	private EditText et_pein_disease_month2;
	private EditText et_pein_disease_year3;
	private EditText et_pein_disease_month3;
	private EditText et_pein_disease_year4;
	private EditText et_pein_disease_month4;
	private EditText et_pein_disease_year5;
	private EditText et_pein_disease_month5;
	private EditText et_pein_disease_year6;
	private EditText et_pein_disease_month6;
	private RadioGroup rg_pein_surgery;
	private RadioButton rb_pein_nonesurgery,rb_pein_surgery;
	private EditText et_pein_surgery_name1;
	private EditText et_pein_surgery_time1;
	private EditText et_pein_surgery_name2;
	private EditText et_pein_surgery_time2;
	private RadioGroup rg_pein_trauma;
	private RadioButton rb_pein_nonetrauma,rb_pein_trauma;
	private EditText et_pein_trauma_name1;
	private EditText et_pein_trauma_time1;
	private EditText et_pein_trauma_name2;
	private EditText et_pein_trauma_time2;
	private RadioGroup rg_pein_transfusion;
	private RadioButton rb_pein_nonetransfusion,rb_pein_transfusion_reason;
	private EditText et_pein_transfusion_reason1;
	private EditText et_pein_transfusion_time1;
	private EditText et_pein_transfusion_reason2;
	private EditText et_pein_transfusion_time2;
	private TextView tv_pein_disease_date1,tv_pein_disease_date2,tv_pein_disease_date3,tv_pein_disease_date4,tv_pein_disease_date5,
	tv_pein_disease_date6;

	private HereTipa ht;
	private PersonInfo person;
	private int profileid = 0;//健康档案编号
	private int n=0,k=0;
	
	public  BuilderView_1(Context context){
		super(context);
		myContext=context;
		
		LayoutInflater factory = LayoutInflater.from(myContext);
		view = factory.inflate(R.layout.build_profile_1, null);
		findViewsById();
		initialize();
		LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		this.addView(view,lp);
		ht = new HereTipa(context);
		person = new PersonInfo(context);
	}
	
	public void setProfileid(int id){
		this.profileid = id;
	}
	
	public String getName(){
		String temp = et_name.getText().toString();
		return temp;
	}
	
	/**
	 * 设置档案创建的初始状态
	 */
	private void initialize() {
		// TODO Auto-generated method stub
		String provice = myContext.getResources().getString(R.string.def_province);
		String city = myContext.getResources().getString(R.string.def_city);
		String county = myContext.getResources().getString(R.string.def_county);
		String rural = myContext.getResources().getString(R.string.def_rural);
		String village = myContext.getSharedPreferences(USERINFO, Context.MODE_PRIVATE).getString("def_village", "");
		
		et_id_card.setText(myContext.getResources().getString(R.string.def_area_code));
		cb_idcard_x.setChecked(false);
		et_address.setText(provice+city+county+rural+village);
		et_household.setText(provice+city+county+rural+village);
		rb_pein_register.setChecked(true);
		rb_pein_han.setChecked(true);
		rb_pein_blood_nonetype.setChecked(true);
		rb_pein_rh_negative_none.setChecked(true);
		rb_pein_noneculture.setChecked(true);
		rb_pein_farmer.setChecked(true);
		rb_pein_unmarriage.setChecked(true);
		cb_pein_newvillage.setChecked(true);
		cb_pein_drug_none.setChecked(true);
		cb_pein_exposure_his_none.setChecked(true);
		cb_pein_disease_none.setChecked(true);
		rb_pein_nonesurgery.setChecked(true);
		rb_pein_nonetrauma.setChecked(true);
		rb_pein_nonetransfusion.setChecked(true);
	}

	private void findViewsById(){
	       
	       et_name=(EditText)view.findViewById(R.id.name);
	       et_id_card=(EditText)view.findViewById(R.id.id_card);
	       cb_idcard_x = (CheckBox)view.findViewById(R.id.id_card_x);
	       et_address=(EditText)view.findViewById(R.id.address);
	       sp_address_team=(Spinner)view.findViewById(R.id.address_team);
	       et_household=(EditText)view.findViewById(R.id.household);
	       sp_household_team=(Spinner)view.findViewById(R.id.household_team);
	       et_pein_phone=(EditText)view.findViewById(R.id.tel);
	       et_pein_work = (EditText)view.findViewById(R.id.work_unit);
	       et_pein_contact_name =(EditText)view.findViewById(R.id.et_pein_contact_name);
	       et_pein_contact_phone = (EditText)view.findViewById(R.id.et_pein_contact_phone);
	       rg_pein_permatent_type = (RadioGroup)view.findViewById(R.id.rg_pein_permatent_type);
	       rb_pein_register=(RadioButton)view.findViewById(R.id.rb_pein_register);
	       rb_pein_unregister=(RadioButton)view.findViewById(R.id.rb_pein_unregister);
	       
	       rg_pein_nation=(RadioGroup)view.findViewById(R.id.rg_pein_nation);
	       rb_pein_han=(RadioButton)view.findViewById(R.id.rb_pein_han);
	       rb_pein_han.setOnClickListener(this);
	       rb_pein_minority=(RadioButton)view.findViewById(R.id.rb_pein_minority);
	       rb_pein_minority.setOnClickListener(this);
	       et_pein_minority=(EditText)view.findViewById(R.id.et_pein_minority);
	       rg_pein_blood_type=(RadioGroup)view.findViewById(R.id.rg_pein_blood_type);
	       rb_pein_blood_Atype=(RadioButton)view.findViewById(R.id.rb_pein_blood_Atype);
	       rb_pein_blood_Btype=(RadioButton)view.findViewById(R.id.rb_pein_blood_Btype);
	       rb_pein_blood_Otype=(RadioButton)view.findViewById(R.id.rb_pein_blood_Otype);
			rb_pein_blood_ABtype=(RadioButton)view.findViewById(R.id.rb_pein_blood_ABtype);
			rb_pein_blood_nonetype=(RadioButton)view.findViewById(R.id.rb_pein_blood_nonetype);
			rg_pein_rh_negative=(RadioGroup)view.findViewById(R.id.rg_pein_rh_negative);
			rb_pein_rh_negative_y=(RadioButton)view.findViewById(R.id.rb_pein_rh_negative_y);
			rb_pein_rh_negative_N=(RadioButton)view.findViewById(R.id.rb_pein_rh_negative_N);
			rb_pein_rh_negative_none=(RadioButton)view.findViewById(R.id.rb_pein_rh_negative_none);
			rg_pein_culture_stdd=(RadioGroup)view.findViewById(R.id.rg_pein_culture_stdd);
			rb_pein_illiteracy=(RadioButton)view.findViewById(R.id.rb_pein_illiteracy);
			rb_pein_grade=(RadioButton)view.findViewById(R.id.rb_pein_grade);
			rb_pein_junior=(RadioButton)view.findViewById(R.id.rb_pein_junior);
			rb_pein_senior=(RadioButton)view.findViewById(R.id.rb_pein_senior);
			rb_pein_college=(RadioButton)view.findViewById(R.id.rb_pein_college);
			rb_pein_noneculture=(RadioButton)view.findViewById(R.id.rb_pein_noneculture);
			rg_pein_occupation=(RadioGroup)view.findViewById(R.id.rg_pein_occupation);
			rb_pein_state_organs=(RadioButton)view.findViewById(R.id.rb_pein_state_organs);
			rb_pein_worker=(RadioButton)view.findViewById(R.id.rb_pein_worker);
			rb_pein_vawirrmqyyoy=(RadioButton)view.findViewById(R.id.rb_pein_vawirrmqyyoy);
			rb_pein_commercial=(RadioButton)view.findViewById(R.id.rb_pein_commercial);
			rb_pein_farmer=(RadioButton)view.findViewById(R.id.rb_pein_farmer);
			rb_pein_production=(RadioButton)view.findViewById(R.id.rb_pein_production);
			rb_pein_soldier=(RadioButton)view.findViewById(R.id.rb_pein_soldier);
			rb_pein_occ_other=(RadioButton)view.findViewById(R.id.rb_pein_occ_other);
			rb_pein_state_organs.setOnClickListener(this);
			rb_pein_worker.setOnClickListener(this);
			rb_pein_vawirrmqyyoy.setOnClickListener(this);
			rb_pein_commercial.setOnClickListener(this);
			rb_pein_farmer.setOnClickListener(this);
			rb_pein_production.setOnClickListener(this);
			rb_pein_soldier.setOnClickListener(this);
			rb_pein_occ_other.setOnClickListener(this);
			rg_pein_marriage=(RadioGroup)view.findViewById(R.id.rg_pein_marriage);
			rb_pein_unmarriage=(RadioButton)view.findViewById(R.id.rb_pein_unmarriage);
			rb_pein_marriaged=(RadioButton)view.findViewById(R.id.rb_pein_marriaged);
			rb_pein_sanghun=(RadioButton)view.findViewById(R.id.rb_pein_sanghun);
			rb_pein_divorce=(RadioButton)view.findViewById(R.id.rb_pein_divorce);
			rb_pein_none_marriage=(RadioButton)view.findViewById(R.id.rb_pein_none_marriage);
			cb_pein_city_worker=(CheckBox)view.findViewById(R.id.cb_pein_city_worker);
			cb_pein_country_resident=(CheckBox)view.findViewById(R.id.cb_pein_country_resident);
			cb_pein_newvillage=(CheckBox)view.findViewById(R.id.cb_pein_newvillage);
			cb_pein_poor=(CheckBox)view.findViewById(R.id.cb_pein_poor);
			cb_pein_trade_hos_insurance=(CheckBox)view.findViewById(R.id.cb_pein_trade_hos_insurance);
			cb_pein_allpubexpense=(CheckBox)view.findViewById(R.id.cb_pein_allpubexpense);
			cb_pein_allpriexpense=(CheckBox)view.findViewById(R.id.cb_pein_allpriexpense);
			cb_pein_hos_cost_other=(CheckBox)view.findViewById(R.id.cb_pein_hos_cost_other);
			cb_pein_city_worker.setOnClickListener(this);
			cb_pein_country_resident.setOnClickListener(this);
			cb_pein_newvillage.setOnClickListener(this);
			cb_pein_poor.setOnClickListener(this);
			cb_pein_trade_hos_insurance.setOnClickListener(this);
			cb_pein_allpubexpense.setOnClickListener(this);
			cb_pein_allpriexpense.setOnClickListener(this);
			cb_pein_hos_cost_other.setOnClickListener(this);
			et_pein_hos_cost_other=(EditText)view.findViewById(R.id.et_pein_hos_cost_other);
			cb_pein_drug_none=(CheckBox)view.findViewById(R.id.cb_pein_drug_none);
			cb_pein_drug_penicillin=(CheckBox)view.findViewById(R.id.cb_pein_drug_penicillin);
			cb_pein_drug_sulfanilamide=(CheckBox)view.findViewById(R.id.cb_pein_drug_sulfanilamide);
			cb_pein_drug_streptomycin=(CheckBox)view.findViewById(R.id.cb_pein_drug_streptomycin);
			cb_pein_drug_other=(CheckBox)view.findViewById(R.id.cb_pein_drug_other);
			cb_pein_drug_none.setOnClickListener(this);
			cb_pein_drug_penicillin.setOnClickListener(this);
			cb_pein_drug_sulfanilamide.setOnClickListener(this);
			cb_pein_drug_streptomycin.setOnClickListener(this);
			cb_pein_drug_other.setOnClickListener(this);
			et_pein_drug_other=(EditText)view.findViewById(R.id.et_pein_drug_other);
			cb_pein_exposure_his_none=(CheckBox)view.findViewById(R.id.cb_pein_exposure_his_none);
			cb_pein_exposure_his_chemistry=(CheckBox)view.findViewById(R.id.cb_pein_exposure_his_chemistry);
			cb_pein_exposure_his_poison=(CheckBox)view.findViewById(R.id.cb_pein_exposure_his_poison);
			cb_pein_exposure_his_radial=(CheckBox)view.findViewById(R.id.cb_pein_exposure_his_radial);
			cb_pein_exposure_his_none.setOnClickListener(this);
			cb_pein_exposure_his_chemistry.setOnClickListener(this);
			cb_pein_exposure_his_poison.setOnClickListener(this);
			cb_pein_exposure_his_radial.setOnClickListener(this);
			cb_pein_disease_none=(CheckBox)view.findViewById(R.id.cb_pein_disease_none);
			cb_pein_disease_hypertension=(CheckBox)view.findViewById(R.id.cb_pein_disease_hypertension);
			cb_pein_disease_diabetesmellitus=(CheckBox)view.findViewById(R.id.cb_pein_disease_diabetesmellitus);
			cb_pein_disease_coronary=(CheckBox)view.findViewById(R.id.cb_pein_disease_coronary);
		    cb_pein_disease_cancer=(CheckBox)view.findViewById(R.id.cb_pein_disease_cancer);
		    cb_pein_disease_lung=(CheckBox)view.findViewById(R.id.cb_pein_disease_lung);
		    cb_pein_disease_stroke=(CheckBox)view.findViewById(R.id.cb_pein_disease_stroke);
			cb_pein_disease_mental=(CheckBox)view.findViewById(R.id.cb_pein_disease_mental);
			cb_pein_disease_tuberculosis=(CheckBox)view.findViewById(R.id.cb_pein_disease_tuberculosis);
			cb_pein_disease_hepatitis=(CheckBox)view.findViewById(R.id.cb_pein_disease_hepatitis);
			cb_pein_disease_othercontagion=(CheckBox)view.findViewById(R.id.cb_pein_disease_othercontagion);
			cb_pein_disease_occ=(CheckBox)view.findViewById(R.id.cb_pein_disease_occ);
			cb_pein_disease_other=(CheckBox)view.findViewById(R.id.cb_pein_disease_other);
			cb_pein_disease_none.setOnClickListener(this);
		
			cb_pein_disease_hypertension.setOnClickListener(this);
			cb_pein_disease_diabetesmellitus.setOnClickListener(this);
			cb_pein_disease_coronary.setOnClickListener(this);
			cb_pein_disease_cancer.setOnClickListener(this);
			cb_pein_disease_lung.setOnClickListener(this);
			cb_pein_disease_stroke.setOnClickListener(this);
			cb_pein_disease_mental.setOnClickListener(this);
			cb_pein_disease_tuberculosis.setOnClickListener(this);
			cb_pein_disease_hepatitis.setOnClickListener(this);
			cb_pein_disease_othercontagion.setOnClickListener(this);
			cb_pein_disease_occ.setOnClickListener(this);
			cb_pein_disease_other.setOnClickListener(this);            
			
			et_pein_disease_cancer=(EditText)view.findViewById(R.id.et_pein_disease_cancer);
			et_pein_disease_occ=(EditText)view.findViewById(R.id.et_pein_disease_occ);
			et_pein_disease_other=(EditText)view.findViewById(R.id.et_pein_disease_other);
			et_pein_disease_year1=(EditText)view.findViewById(R.id.et_pein_disease_year1);
			et_pein_disease_month1=(EditText)view.findViewById(R.id.et_pein_disease_month1);
			et_pein_disease_year2=(EditText)view.findViewById(R.id.et_pein_disease_year2);
			et_pein_disease_month2=(EditText)view.findViewById(R.id.et_pein_disease_month2);
			et_pein_disease_year3=(EditText)view.findViewById(R.id.et_pein_disease_year3);
			et_pein_disease_month3=(EditText)view.findViewById(R.id.et_pein_disease_month3);
			et_pein_disease_year4=(EditText)view.findViewById(R.id.et_pein_disease_year4);
			et_pein_disease_month4=(EditText)view.findViewById(R.id.et_pein_disease_month4);
			et_pein_disease_year5=(EditText)view.findViewById(R.id.et_pein_disease_year5);
			et_pein_disease_month5=(EditText)view.findViewById(R.id.et_pein_disease_month5);
			et_pein_disease_year6=(EditText)view.findViewById(R.id.et_pein_disease_year6);
			et_pein_disease_month6=(EditText)view.findViewById(R.id.et_pein_disease_month6);
			
			rg_pein_surgery=(RadioGroup)view.findViewById(R.id.rg_pein_surgery);
			rb_pein_nonesurgery=(RadioButton)view.findViewById(R.id.rb_pein_nonesurgery);
			rb_pein_nonesurgery.setOnClickListener(this);
			rb_pein_surgery=(RadioButton)view.findViewById(R.id.rb_pein_surgery);
			rb_pein_surgery.setOnClickListener(this);
			et_pein_surgery_name1=(EditText)view.findViewById(R.id.et_pein_surgery_name1);
			et_pein_surgery_time1=(EditText)view.findViewById(R.id.et_pein_surgery_time1);
			et_pein_surgery_time1.setInputType(InputType.TYPE_NULL);
			et_pein_surgery_time1.setOnClickListener(this);
			et_pein_surgery_name2=(EditText)view.findViewById(R.id.et_pein_surgery_name2);
			et_pein_surgery_time2=(EditText)view.findViewById(R.id.et_pein_surgery_time2);
			et_pein_surgery_time2.setInputType(InputType.TYPE_NULL);
			et_pein_surgery_time2.setOnClickListener(this);
			rg_pein_trauma=(RadioGroup)view.findViewById(R.id.rg_pein_trauma);
			rb_pein_nonetrauma=(RadioButton)view.findViewById(R.id.rb_pein_nonetrauma);
			rb_pein_nonetrauma.setOnClickListener(this);
			rb_pein_trauma=(RadioButton)view.findViewById(R.id.rb_pein_trauma);
			rb_pein_trauma.setOnClickListener(this);
			et_pein_trauma_name1=(EditText)view.findViewById(R.id.et_pein_trauma_name1);
			et_pein_trauma_time1=(EditText)view.findViewById(R.id.et_pein_trauma_time1);
			et_pein_trauma_time1.setInputType(InputType.TYPE_NULL);
			et_pein_trauma_time1.setOnClickListener(this);
			et_pein_trauma_name2=(EditText)view.findViewById(R.id.et_pein_trauma_name2);
			et_pein_trauma_time2=(EditText)view.findViewById(R.id.et_pein_trauma_time2);
			et_pein_trauma_time2.setInputType(InputType.TYPE_NULL);
			et_pein_trauma_time2.setOnClickListener(this);
			rg_pein_transfusion=(RadioGroup)view.findViewById(R.id.rg_pein_transfusion);
			rb_pein_nonetransfusion=(RadioButton)view.findViewById(R.id.rb_pein_nonetransfusion);
			rb_pein_nonetransfusion.setOnClickListener(this);
			rb_pein_transfusion_reason=(RadioButton)view.findViewById(R.id.rb_pein_transfusion_reason);
			rb_pein_transfusion_reason.setOnClickListener(this);
			et_pein_transfusion_reason1=(EditText)view.findViewById(R.id.et_pein_transfusion_reason1);
			et_pein_transfusion_time1=(EditText)view.findViewById(R.id.et_pein_transfusion_time1);
			et_pein_transfusion_time1.setInputType(InputType.TYPE_NULL);
			et_pein_transfusion_time1.setOnClickListener(this);
			et_pein_transfusion_reason2=(EditText)view.findViewById(R.id.et_pein_transfusion_reason2);
			et_pein_transfusion_time2=(EditText)view.findViewById(R.id.et_pein_transfusion_time2);
			et_pein_transfusion_time2.setInputType(InputType.TYPE_NULL);
			et_pein_transfusion_time2.setOnClickListener(this);

			tv_pein_disease_date1=(TextView)view.findViewById(R.id.tv_pein_disease_date1);
			tv_pein_disease_date2=(TextView)view.findViewById(R.id.tv_pein_disease_date2);
			tv_pein_disease_date3=(TextView)view.findViewById(R.id.tv_pein_disease_date3);
			tv_pein_disease_date4=(TextView)view.findViewById(R.id.tv_pein_disease_date4);
			tv_pein_disease_date5=(TextView)view.findViewById(R.id.tv_pein_disease_date5);
			tv_pein_disease_date6=(TextView)view.findViewById(R.id.tv_pein_disease_date6);

	}
   	
   	/**
	 * 检查信息的完整性，必填项不能为空
	 * @return 完整 true，否之 false
	 */
	public boolean checkIntegrity() {
		// TODO Auto-generated method stub
		String temp;
		temp = et_name.getText().toString();
		if(temp.length()==0){
			Toast.makeText(myContext, "请填写姓名！", Toast.LENGTH_LONG).show();
			return false;
		}
		temp = et_id_card.getText().toString();
		if(temp.length()==0){
			Toast.makeText(myContext, "请填写身份证号码！", Toast.LENGTH_LONG).show();
			return false;
		}
		IDCard card = new IDCard(temp);
		if(!(card.isValid())){
			Toast.makeText(myContext, "身份证号码有错误，请核查！", Toast.LENGTH_LONG).show();
			return false;
		}
		temp = et_address.getText().toString();
		if(temp.length()==0){
			Toast.makeText(myContext, "请填写现住址！", Toast.LENGTH_LONG).show();
			return false;
		}
		temp = et_household.getText().toString();
		if(temp.length()==0){
			Toast.makeText(myContext, "请填写户籍地址！", Toast.LENGTH_LONG).show();
			return false;
		}
		if(rg_pein_permatent_type.getCheckedRadioButtonId()==-1){
			Toast.makeText(myContext, "请选择常住类型！", Toast.LENGTH_LONG).show();
			return false;
		}
		temp = et_pein_minority.getText().toString();
		if((rg_pein_nation.getCheckedRadioButtonId()==-1)){
			Toast.makeText(myContext, "请选择民族！", Toast.LENGTH_LONG).show();
			return false;
		}
		if((rg_pein_nation.getCheckedRadioButtonId()==1)&&temp.length()==0){
			Toast.makeText(myContext, "请填写少数民族！", Toast.LENGTH_LONG).show();
			return false;
		}
		if(rg_pein_blood_type.getCheckedRadioButtonId()==-1){
			Toast.makeText(myContext, "请选择血型！", Toast.LENGTH_LONG).show();
			return false;
		}
		if(rg_pein_rh_negative.getCheckedRadioButtonId()==-1){
			Toast.makeText(myContext, "请选择RH阴性！", Toast.LENGTH_LONG).show();
			return false;
		}
		if(rg_pein_culture_stdd.getCheckedRadioButtonId()==-1){
			Toast.makeText(myContext, "请选择文化程度！", Toast.LENGTH_LONG).show();
			return false;
		}
		if(!isOccupationSet()){
			Toast.makeText(myContext, "请选择职业！", Toast.LENGTH_LONG).show();
			return false;
		}
		if(rg_pein_marriage.getCheckedRadioButtonId()==-1){
			Toast.makeText(myContext, "请选择婚姻状况！", Toast.LENGTH_LONG).show();
			return false;
		}
		return true;
	}
	
   
   	private boolean isOccupationSet() {
		// TODO Auto-generated method stub
   		if(rb_pein_state_organs.isChecked()==true){
   			return true;
   		}
   		if(rb_pein_worker.isChecked()==true){
   			return true;
   		}
   		if(rb_pein_vawirrmqyyoy.isChecked()==true){
   			return true;
   		}
   		if(rb_pein_commercial.isChecked()==true){
   			return true;
   		}
   		if(rb_pein_farmer.isChecked()==true){
   			return true;
   		}
   		if(rb_pein_production.isChecked()==true){
   			return true;
   		}
   		if(rb_pein_soldier.isChecked()==true){
   			return true;
   		}
   		if(rb_pein_occ_other.isChecked()==true){
   			return true;
   		}
		return false;
	}

	//保存
   	public void saveViews(){
   		ht.selectHereTipa(profileid);
   		person.selectPersonInfo(profileid);
   		
   		String temp="";
   		
   		ht.setHeti_name(et_name.getText().toString());
   		
   		temp = et_id_card.getText().toString();
   		if(cb_idcard_x.isChecked()==true){
   			person.setPein_perid(temp+"x");   			
   		}
   		else{
   			person.setPein_perid(temp);
   		}
   		IDCard card = new IDCard(temp);
   		person.setPein_born(card.getBirthday());
   		int gender = card.getGender();
   		switch(gender){
   		case 0://女
   			person.setPein_sex(2);
   			break;
   		case 1://男
   			person.setPein_sex(1);
   			break;
   		}
   		
   		temp = et_address.getText().toString()+sp_address_team.getSelectedItem().toString();
   		ht.setHeti_now_addr(temp);
   		temp = et_household.getText().toString()+sp_household_team.getSelectedItem().toString();
   		ht.setHeti_hore_addr(temp);
   		
   		temp = et_pein_phone.getText().toString();
   		ht.setHeti_tel(temp);
   		person.setPein_phone(temp);
 	    person.setPein_work(et_pein_work.getText().toString());
 	    person.setPein_contact_name(et_pein_contact_name.getText().toString());
 	    person.setPein_contact_phone(et_pein_contact_phone.getText().toString());
 	    if(rb_pein_register.isChecked()){person.setPein_permatent_type(1);}
	    else if(rb_pein_unregister.isChecked()){person.setPein_permatent_type(2);}
 	    if(rb_pein_han.isChecked()){person.setPein_nation(1);}
		else if(rb_pein_minority.isChecked()){
			person.setPein_nation(2);
			person.setPein_minority(et_pein_minority.getText().toString());
		}
 	  	if(rb_pein_blood_Atype.isChecked()){person.setPein_blood_type(1);}
		else if(rb_pein_blood_Btype.isChecked()){person.setPein_blood_type(2);}
		else if(rb_pein_blood_Otype.isChecked()){person.setPein_blood_type(3);}
		else if(rb_pein_blood_ABtype.isChecked()){person.setPein_blood_type(4);}
		else if(rb_pein_blood_nonetype.isChecked()){person.setPein_blood_type(5);}
	 	if(rb_pein_rh_negative_y.isChecked()){person.setPein_rh_negative(1);}
		else if(rb_pein_rh_negative_N.isChecked()){person.setPein_rh_negative(2);}
		else if(rb_pein_rh_negative_none.isChecked()){person.setPein_rh_negative(3);}
	 	if(rb_pein_illiteracy.isChecked()){person.setPein_culture_stdd(1);}
		else if(rb_pein_grade.isChecked()){person.setPein_culture_stdd(2);}
		else if(rb_pein_junior.isChecked()){person.setPein_culture_stdd(3);}
		else if(rb_pein_senior.isChecked()){person.setPein_culture_stdd(4);}
		else if(rb_pein_college.isChecked()){person.setPein_culture_stdd(5);}
		else if(rb_pein_noneculture.isChecked()){person.setPein_culture_stdd(6);}
	 	if(rb_pein_state_organs.isChecked()){person.setPein_occupation(1);}
		else if(rb_pein_worker.isChecked()){person.setPein_occupation(2);}
		else if(rb_pein_vawirrmqyyoy.isChecked()){person.setPein_occupation(3);}
		else if(rb_pein_commercial.isChecked()){person.setPein_occupation(4);}
		else if(rb_pein_farmer.isChecked()){person.setPein_occupation(5);}
		else if(rb_pein_production.isChecked()){person.setPein_occupation(6);}
		else if(rb_pein_soldier.isChecked()){person.setPein_occupation(7);}
		else if(rb_pein_occ_other.isChecked()){person.setPein_occupation(8);}
	 	if(rb_pein_unmarriage.isChecked()){
	 		person.setPein_marriage(1);}
		else if(rb_pein_marriaged.isChecked()){
	 		person.setPein_marriage(2);}
		else if(rb_pein_sanghun.isChecked()){
			person.setPein_marriage(3);}
		else if(rb_pein_divorce.isChecked()){
			person.setPein_marriage(4);}
		else if(rb_pein_none_marriage.isChecked()){
			person.setPein_marriage(5);}
	 	
	 	person.setPein_hos_cost_type(pein_hos_cost_type());
	 	if(cb_pein_hos_cost_other.isChecked()){
	 		person.setPein_hos_cost_type_ot(et_pein_hos_cost_other.getText().toString());
	 	}
	 	person.setPein_drug_allergy(pein_drug_allergy());
	 	if(cb_pein_drug_other.isChecked()){
	 		person.setPein_drug_allergy_ot(et_pein_drug_other.getText().toString());
	 	}
	 	person.setPein_exposure_his(pein_exposure_his());
	 	person.setPein_disease(pein_disease());
	 	if(cb_pein_disease_cancer.isChecked()){
	 		person.setPein_cancer(et_pein_disease_cancer.getText().toString());
	 	}
	 	if(cb_pein_disease_occ.isChecked()){
	 		person.setPein_occ_dis(et_pein_disease_occ.getText().toString());
	 	}
	 	if(cb_pein_disease_other.isChecked()){
	 		person.setPein_disease_ot(et_pein_disease_other.getText().toString());
	 	}
	 	person.setPein_disease_date(tv_pein_disease_date1.getText().toString()+"-" +
				 et_pein_disease_year1.getText().toString()+"-"+
				 et_pein_disease_month1.getText().toString()+","+
				 tv_pein_disease_date2.getText().toString()+"-"+ 
				 et_pein_disease_year2.getText().toString()+"-"+
				 et_pein_disease_month2.getText().toString()+","+
				 tv_pein_disease_date3.getText().toString()+"-"+ 
				 et_pein_disease_year3.getText().toString()+"-"+
				 et_pein_disease_month3.getText().toString()+","+
				 tv_pein_disease_date4.getText().toString()+"-"+ 
				 et_pein_disease_year4.getText().toString()+"-"+
				 et_pein_disease_month4.getText().toString()+","+
				 tv_pein_disease_date5.getText().toString()+"-"+ 
				 et_pein_disease_year5.getText().toString()+"-"+
				 et_pein_disease_month5.getText().toString()+","+
				 tv_pein_disease_date6.getText().toString()+"-"+
				 et_pein_disease_year6.getText().toString()+"-"+
				 et_pein_disease_month6.getText().toString());
	 	if(rb_pein_nonesurgery.isChecked()){person.setPein_surgery(1);}
		else if(rb_pein_surgery.isChecked()){
			person.setPein_surgery(2);
			person.setPein_surgery_name1(et_pein_surgery_name1.getText().toString());
			person.setPein_surgery_date1(et_pein_surgery_time1.getText().toString());
			person.setPein_surgery_name2(et_pein_surgery_name2.getText().toString());
			person.setPein_surgery_date2(et_pein_surgery_time2.getText().toString());
		}
	 	if(rb_pein_nonetrauma.isChecked()){person.setPein_trauma(1);}
		else if(rb_pein_trauma.isChecked()){
			person.setPein_trauma(2);
			person.setPein_trauma_name1(et_pein_trauma_name1.getText().toString());
			person.setPein_trauma_time1(et_pein_trauma_time1.getText().toString());
			person.setPein_trauma_name2(et_pein_trauma_name2.getText().toString());
			person.setPein_trauma_time2(et_pein_trauma_time2.getText().toString());
		}
	 	if(rb_pein_nonetransfusion.isChecked()){person.setPein_transfusion(1);}
		else if(rb_pein_transfusion_reason.isChecked()){
			person.setPein_transfusion(2);
			person.setPein_trfusion_reason1(et_pein_transfusion_reason1.getText().toString());
			person.setPein_trfusion_time1(et_pein_transfusion_time1.getText().toString());
			person.setPein_trfusion_reason2(et_pein_transfusion_reason2.getText().toString());
			person.setPein_trfusion_time2(et_pein_transfusion_time2.getText().toString());
		}
	 	ht.updateHereTipa(profileid);
	 	person.updatePersonInfo(profileid);	
   	}
   	
   	
   	public String pein_hos_cost_type(){
		String r="";
	//	int j=0;
		String m="";
		CheckBox []cb_pein_hos_cost_type={cb_pein_city_worker,cb_pein_country_resident,cb_pein_newvillage,cb_pein_poor,
											cb_pein_trade_hos_insurance,cb_pein_allpubexpense,
											cb_pein_allpriexpense,cb_pein_hos_cost_other};
		
			for(int i=0;i<cb_pein_hos_cost_type.length;i++){
				if(cb_pein_hos_cost_type[i].isChecked()){
					m=Integer.toString(i+1);
					r=r+m+",";
		//			j++;
				}
		//		if(j>=3){cb_pein_hos_cost_type[i].setEnabled(false);}
			}
		return r;
	}
   	public String pein_drug_allergy(){
		String r="";
	//	int j=0;
		String m="";
		CheckBox []cb_pein_drug_allergy={cb_pein_drug_none,cb_pein_drug_penicillin,cb_pein_drug_sulfanilamide,
										 cb_pein_drug_streptomycin,cb_pein_drug_other};
		
	//	if(cb_pein_drug_none.isChecked()){
	//		r="1";
		//	for(int i=0;i<cb_pein_drug_allergy.length;i++){
		//		cb_pein_drug_allergy[i].setEnabled(false);
		//	}
	//	}
		
			for(int i=0;i<cb_pein_drug_allergy.length;i++){
				if(cb_pein_drug_allergy[i].isChecked()){
					m=Integer.toString(i+1);
					r=r+m+",";
				//	j++;
				}
			//	if(j>=4){cb_pein_drug_allergy[i].setEnabled(false);}
			}
		return r;
	}
   	public String pein_exposure_his(){
		String r="";
	//	int j=0;
		String m="";
		CheckBox []cb_pein_exposure_his={cb_pein_exposure_his_none,cb_pein_exposure_his_chemistry,
										cb_pein_exposure_his_poison,cb_pein_exposure_his_radial};
		
		
		
			for(int i=0;i<cb_pein_exposure_his.length;i++){
				if(cb_pein_exposure_his[i].isChecked()){
					m=Integer.toString(i+1);
					r=r+m+",";
		//			j++;
				}
			//	if(j>=3){cb_pein_exposure_his[i].setEnabled(false);}
			}
		return r;
	}
   	public String pein_disease(){
		String r="";
	//	int j=0;
		String m="";
		CheckBox []cb_pein_disease={cb_pein_disease_none,cb_pein_disease_hypertension,cb_pein_disease_diabetesmellitus,
							cb_pein_disease_coronary,cb_pein_disease_cancer,cb_pein_disease_lung,
							cb_pein_disease_stroke,cb_pein_disease_mental,cb_pein_disease_tuberculosis,
							cb_pein_disease_hepatitis,cb_pein_disease_othercontagion,
							cb_pein_disease_occ,cb_pein_disease_other};
		
	
			for(int i=0;i<cb_pein_disease.length;i++){
				if(cb_pein_disease[i].isChecked()){
					m=Integer.toString(i+1);
					r=r+m+",";
			//		j++;
			/*		if(i<10){
						tv_pein_disease_date[j].setText("0"+m);
					}else{
						tv_pein_disease_date[j].setText(m);
					}  */
				}  
			//	if(j>=6){cb_pein_disease[i].setEnabled(false);}  
			}
	//	}
		return r;
	}
   	
    //为某些组件设置监听事件
    
    public void onFocusChange(View v, boolean hasFocus) {
		// TODO Auto-generated method stub
		
    }
	
    
    
    
    public void onClick(View v) {
		// TODO Auto-generated method stub  	
		if(v==rb_pein_han){
			if(rb_pein_han.isChecked()){
				et_pein_minority.setText("");
				et_pein_minority.setEnabled(false);
			}
			else{
				et_pein_minority.setEnabled(true);
			} 
		}
		else if(v==rb_pein_minority){
			et_pein_minority.requestFocus();
			et_pein_minority.setEnabled(true);
		}
		else if(v==rb_pein_state_organs){
			rb_pein_state_organs.setChecked(true);
//			occupationSet = true;
			rb_pein_worker.setChecked(false);
			rb_pein_vawirrmqyyoy.setChecked(false);
			rb_pein_commercial.setChecked(false);
			rb_pein_farmer.setChecked(false);
			rb_pein_production.setChecked(false);
			rb_pein_soldier.setChecked(false);
			rb_pein_occ_other.setChecked(false);
		}
		else if(v==rb_pein_worker){
			rb_pein_state_organs.setChecked(false);
			rb_pein_worker.setChecked(true);
//			occupationSet = true;
			rb_pein_vawirrmqyyoy.setChecked(false);
			rb_pein_commercial.setChecked(false);
			rb_pein_farmer.setChecked(false);
			rb_pein_production.setChecked(false);
			rb_pein_soldier.setChecked(false);
			rb_pein_occ_other.setChecked(false);
		}
		else if(v==rb_pein_vawirrmqyyoy){
			rb_pein_state_organs.setChecked(false);
			rb_pein_worker.setChecked(false);
			rb_pein_vawirrmqyyoy.setChecked(true);
//			occupationSet = true;
			rb_pein_commercial.setChecked(false);
			rb_pein_farmer.setChecked(false);
			rb_pein_production.setChecked(false);
			rb_pein_soldier.setChecked(false);
			rb_pein_occ_other.setChecked(false);
		}
		else if(v==rb_pein_commercial){
			rb_pein_state_organs.setChecked(false);
			rb_pein_worker.setChecked(false);
			rb_pein_vawirrmqyyoy.setChecked(false);
			rb_pein_commercial.setChecked(true);
//			occupationSet = true;
			rb_pein_farmer.setChecked(false);
			rb_pein_production.setChecked(false);
			rb_pein_soldier.setChecked(false);
			rb_pein_occ_other.setChecked(false);
		}
		else if(v==rb_pein_farmer){
			rb_pein_state_organs.setChecked(false);
			rb_pein_worker.setChecked(false);
			rb_pein_vawirrmqyyoy.setChecked(false);
			rb_pein_commercial.setChecked(false);
			rb_pein_farmer.setChecked(true);
//			occupationSet = true;
			rb_pein_production.setChecked(false);
			rb_pein_soldier.setChecked(false);
			rb_pein_occ_other.setChecked(false);
		}
		else if(v==rb_pein_production){
			rb_pein_state_organs.setChecked(false);
			rb_pein_worker.setChecked(false);
			rb_pein_vawirrmqyyoy.setChecked(false);
			rb_pein_commercial.setChecked(false);
			rb_pein_farmer.setChecked(false);
			rb_pein_production.setChecked(true);
//			occupationSet = true;
			rb_pein_soldier.setChecked(false);
			rb_pein_occ_other.setChecked(false);
		}
		else if(v==rb_pein_soldier){
			rb_pein_state_organs.setChecked(false);
			rb_pein_worker.setChecked(false);
			rb_pein_vawirrmqyyoy.setChecked(false);
			rb_pein_commercial.setChecked(false);
			rb_pein_farmer.setChecked(false);
			rb_pein_production.setChecked(false);
			rb_pein_soldier.setChecked(true);
//			occupationSet = true;
			rb_pein_occ_other.setChecked(false);
		}
		else if(v==rb_pein_occ_other){
			rb_pein_state_organs.setChecked(false);
			rb_pein_worker.setChecked(false);
			rb_pein_vawirrmqyyoy.setChecked(false);
			rb_pein_commercial.setChecked(false);
			rb_pein_farmer.setChecked(false);
			rb_pein_production.setChecked(false);
			rb_pein_soldier.setChecked(false);
			rb_pein_occ_other.setChecked(true);
//			occupationSet = true;
		}

		else if(v==cb_pein_city_worker){
	  		if(cb_pein_city_worker.isChecked()){
				n++;	
			}
			else{n--;}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_city_worker.setChecked(false);
				n--;
			}
			
			System.out.println(n);
		}
		
		else if(v==cb_pein_country_resident){
			if(cb_pein_country_resident.isChecked()){
				n++;
				}
			else{n--;}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_country_resident.setChecked(false); 
				n--;
			}
			System.out.println(n);
		}
		else if(v==cb_pein_newvillage){
			if(cb_pein_newvillage.isChecked()){
				n++;				
			}
			else{n--;}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_newvillage.setChecked(false);
				n--;
			}
			System.out.println(n);
		}
		else if(v==cb_pein_poor){
			if(cb_pein_poor.isChecked()){
				n++;		
			}
			else{n--;}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_poor.setChecked(false);
				n--;
			}
			System.out.println(n);
		}
		else if(v==cb_pein_trade_hos_insurance){
			if(cb_pein_trade_hos_insurance.isChecked()){
				n++;
			}
			else{n--;}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_trade_hos_insurance.setChecked(false);
				n--;
			}
			System.out.println(n);
		}
		else if(v==cb_pein_allpubexpense){
			if(cb_pein_allpubexpense.isChecked()){
				n++;
			}
			else{n--;}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_allpubexpense.setChecked(false);
				n--;
			}
			System.out.println(n);
		}
		else if(v==cb_pein_allpriexpense){
			if(cb_pein_allpriexpense.isChecked()){
				n++;
			}
			else{n--;}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_allpriexpense.setChecked(false);
				n--;
			}
			System.out.println(n);
		}
		else if(v==cb_pein_hos_cost_other){
			if(cb_pein_hos_cost_other.isChecked()){
				n++;
				et_pein_hos_cost_other.requestFocus();
				et_pein_hos_cost_other.setEnabled(true);
			}
			else{
				n--;
				et_pein_hos_cost_other.setText("");
				et_pein_hos_cost_other.setEnabled(false);
				}
			if(n>3){
				Toast.makeText(getContext(), "最多可选三项",
					Toast.LENGTH_SHORT).show();
				cb_pein_hos_cost_other.setChecked(false);
				n--;
			}
			System.out.println(n);
		}
		else if(v==cb_pein_drug_none){
		//	cb_pein_drug_none.setChecked(true);
			cb_pein_drug_penicillin.setChecked(false);
			cb_pein_drug_sulfanilamide.setChecked(false);
			cb_pein_drug_streptomycin.setChecked(false);
			cb_pein_drug_other.setChecked(false);
			et_pein_drug_other.setText("");
		}
		else if(v==cb_pein_drug_penicillin){
			cb_pein_drug_none.setChecked(false);
		}
		else if(v==cb_pein_drug_sulfanilamide){
			cb_pein_drug_none.setChecked(false);
		}
		else if(v==cb_pein_drug_streptomycin){
			cb_pein_drug_none.setChecked(false);
		}
		else if(v==cb_pein_drug_other){
			cb_pein_drug_none.setChecked(false);
			if(cb_pein_drug_other.isChecked()){
				et_pein_drug_other.requestFocus();
				et_pein_drug_other.setEnabled(true);
			}else{
				et_pein_drug_other.setEnabled(false);
				et_pein_drug_other.setText("");
			}
		}
		else if(v==cb_pein_exposure_his_none){
		//	cb_pein_exposure_his_none.setChecked(true);
			cb_pein_exposure_his_chemistry.setChecked(false);
			cb_pein_exposure_his_poison.setChecked(false);
			cb_pein_exposure_his_radial.setChecked(false);
			
		}
		else if(v==cb_pein_exposure_his_chemistry){
			cb_pein_exposure_his_none.setChecked(false);
		}
		else if(v==cb_pein_exposure_his_poison){
			cb_pein_exposure_his_none.setChecked(false);
		}
		else if(v==cb_pein_exposure_his_radial){
			cb_pein_exposure_his_none.setChecked(false);
		}
		else if(v==cb_pein_disease_none){
		//	cb_pein_disease_none.setChecked(true);
			cb_pein_disease_hypertension.setChecked(false);
			cb_pein_disease_diabetesmellitus.setChecked(false);
			cb_pein_disease_coronary.setChecked(false);
			cb_pein_disease_cancer.setChecked(false);
			cb_pein_disease_lung.setChecked(false);
			cb_pein_disease_stroke.setChecked(false);
			cb_pein_disease_mental.setChecked(false);
			cb_pein_disease_tuberculosis.setChecked(false);
			cb_pein_disease_hepatitis.setChecked(false);
			cb_pein_disease_othercontagion.setChecked(false);
			cb_pein_disease_occ.setChecked(false);
			cb_pein_disease_other.setChecked(false);
			tv_pein_disease_date1.setText("");
			tv_pein_disease_date2.setText("");
			tv_pein_disease_date3.setText("");
			tv_pein_disease_date4.setText("");
			tv_pein_disease_date5.setText("");
			tv_pein_disease_date6.setText("");
			et_pein_disease_year1.setText("");
			et_pein_disease_month1.setText("");
			et_pein_disease_year2.setText("");
			et_pein_disease_month2.setText("");
			et_pein_disease_year3.setText("");
			et_pein_disease_month3.setText("");
			et_pein_disease_year4.setText("");
			et_pein_disease_month4.setText("");
			et_pein_disease_year5.setText("");
			et_pein_disease_month5.setText("");
			et_pein_disease_year6.setText("");
			et_pein_disease_month6.setText("");
			k=0;
		}
		else if(v==cb_pein_disease_hypertension){
			if(cb_pein_disease_hypertension.isChecked()){
				k++;
				cb_pein_disease_none.setChecked(false);
		/*		for(int j=0;j<tv_pein_disease_date.length;j++){
					if(!tv_pein_disease_date[j].isSelected()){
						tv_pein_disease_date[j].setText("02");   
					//	tv_pein_disease_date[j].get;
						
					}
					break;
				}     */ 
				
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("02");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("02");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("02");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("02");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("02");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("02");
				}      
			}
			else{
				k--;
				if(tv_pein_disease_date1.getText().toString()=="02"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="02"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="02"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="02"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="02"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="02"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}
			}       
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_hypertension.setChecked(false);
				k--;
			}
			
		}
		else if(v==cb_pein_disease_diabetesmellitus){
			if(cb_pein_disease_diabetesmellitus.isChecked()){
				cb_pein_disease_none.setChecked(false);
				k++;
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("03");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("03");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("03");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("03");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("03");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("03");
				}    
			}
			else{
				k--;
				if(tv_pein_disease_date1.getText().toString()=="03"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="03"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="03"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="03"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString() =="03"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="03"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_diabetesmellitus.setChecked(false);
				k--;
			}
		}
		else if(v==cb_pein_disease_coronary){		
			if(cb_pein_disease_coronary.isChecked()){
				cb_pein_disease_none.setChecked(false);
				k++;
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("04");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("04");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("04");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("04");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("04");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("04");
				}   
			}
			else{
				k--;
				if(tv_pein_disease_date1.getText().toString()=="04"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="04"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="04"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="04"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="04"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="04"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_coronary.setChecked(false);
				k--;
			}
		}
		else if(v==cb_pein_disease_cancer){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_cancer.isChecked()){
				k++;
				et_pein_disease_cancer.requestFocus();
				cb_pein_disease_cancer.setEnabled(true);
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("05");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("05");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("05");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("05");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("05");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("05");
				}   
			}
			else {
				k--;
				cb_pein_disease_cancer.setEnabled(false);
				et_pein_disease_cancer.setText("");
				if(tv_pein_disease_date1.getText().toString()=="05"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="05"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="05"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="05"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="05"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="05"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_cancer.setChecked(false);
				k--;
			}
		}
		else if(v==cb_pein_disease_lung){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_lung.isChecked()){
				k++;
					if(!(tv_pein_disease_date1.getText().toString().length()>0)){
						tv_pein_disease_date1.setText("06");	
					}
					else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
						tv_pein_disease_date2.setText("06");
					}
					else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
						tv_pein_disease_date3.setText("06");
					}
					else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
						tv_pein_disease_date4.setText("06");
					}
					else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
						tv_pein_disease_date5.setText("06");
					}
					else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
						tv_pein_disease_date6.setText("06");
					}   
				}
				else {
					k--;
					if(tv_pein_disease_date1.getText().toString()=="06"){
						tv_pein_disease_date1.setText("");
						et_pein_disease_year1.setText("");
						et_pein_disease_month1.setText("");
					}
					else if(tv_pein_disease_date2.getText().toString()=="06"){
						tv_pein_disease_date2.setText("");
						et_pein_disease_year2.setText("");
						et_pein_disease_month2.setText("");
					}
					else if(tv_pein_disease_date3.getText().toString()=="06"){
						tv_pein_disease_date3.setText("");
						et_pein_disease_year3.setText("");
						et_pein_disease_month3.setText("");
					}
					else if(tv_pein_disease_date4.getText().toString()=="06"){
						tv_pein_disease_date4.setText("");
						et_pein_disease_year4.setText("");
						et_pein_disease_month4.setText("");
					}
					else if(tv_pein_disease_date5.getText().toString()=="06"){
						tv_pein_disease_date5.setText("");
						et_pein_disease_year5.setText("");
						et_pein_disease_month5.setText("");
					}
					else if(tv_pein_disease_date6.getText().toString()=="06"){
						tv_pein_disease_date6.setText("");
						et_pein_disease_year6.setText("");
						et_pein_disease_month6.setText("");
					}	
				}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_lung.setChecked(false);
				k--;
			}
		}
		else if(v==cb_pein_disease_stroke){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_stroke.isChecked()){
				k++;
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("07");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("07");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("07");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("07");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("07");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("07");
				}   
			}
			else {
				k--;
				if(tv_pein_disease_date1.getText().toString()=="07"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="07"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="07"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="07"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="07"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="07"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_stroke.setChecked(false);
				k--;
			}
	/*		for(int j=0;j<tv_pein_disease_date.length;j++){
				if(!tv_pein_disease_date[j].isEnabled()){
					tv_pein_disease_date[j].setText("07");
				}
				break;
			}*/
		}
		else if(v==cb_pein_disease_mental){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_mental.isChecked()){
				k++;
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("08");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("08");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("08");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("08");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("08");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("08");
				}   
			}
			else {
				k--;
				if(tv_pein_disease_date1.getText().toString()=="08"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="08"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="08"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="08"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="08"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="08"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_mental.setChecked(false);
				k--;
			}
/*			for(int j=0;j<tv_pein_disease_date.length;j++){
				if(!tv_pein_disease_date[j].isEnabled()){
					tv_pein_disease_date[j].setText("08");
				}
				break;
			}*/
		}
		else if(v==cb_pein_disease_tuberculosis){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_tuberculosis.isChecked()){
				k++;
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("09");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("09");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("09");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("09");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("09");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("09");
				}   
			}
			else {
				k--;
				if(tv_pein_disease_date1.getText().toString()=="09"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="09"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="09"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="09"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="09"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="09"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_tuberculosis.setChecked(false);
				k--;
			}
	/*		for(int j=0;j<tv_pein_disease_date.length;j++){
				if(!tv_pein_disease_date[j].isEnabled()){
					tv_pein_disease_date[j].setText("09");
				}
				break;
			}*/
		}
		else if(v==cb_pein_disease_hepatitis){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_hepatitis.isChecked()){
				k++;
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("10");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("10");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("10");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("10");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("10");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("10");
				}   
			}
			else {
				k--;
				if(tv_pein_disease_date1.getText().toString()=="10"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="10"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="10"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="10"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="10"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="10"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_hepatitis.setChecked(false);
				k--;
			}
		/*	for(int j=0;j<tv_pein_disease_date.length;j++){
				if(!tv_pein_disease_date[j].isEnabled()){
					tv_pein_disease_date[j].setText("10");
				}
				break;
			}*/
		}
		else if(v==cb_pein_disease_othercontagion){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_othercontagion.isChecked()){
				k++;
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("11");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("11");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("11");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("11");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("11");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("11");
				}   
			}
			else {
				k--;
				if(tv_pein_disease_date1.getText().toString()=="11"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="11"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="11"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="11"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="11"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="11"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_othercontagion.setChecked(false);
				k--;
			}
		/*	for(int j=0;j<tv_pein_disease_date.length;j++){
				if(!tv_pein_disease_date[j].isEnabled()){
					tv_pein_disease_date[j].setText("11");
				}
				break;
			}*/
		}
		else if(v==cb_pein_disease_occ){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_occ.isChecked()){
				k++;
				et_pein_disease_occ.requestFocus();
				et_pein_disease_occ.setEnabled(true);
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("12");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("12");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("12");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("12");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("12");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("12");
				}   
			}
			else {
				k--;
				et_pein_disease_occ.setEnabled(false);
				et_pein_disease_occ.setText("");
				if(tv_pein_disease_date1.getText().toString()=="12"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="12"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="12"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="12"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="12"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="12"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_occ.setChecked(false);
				k--;
			}
	/*		for(int j=0;j<tv_pein_disease_date.length;j++){
				if(!tv_pein_disease_date[j].isEnabled()){
					tv_pein_disease_date[j].setText("12");
				}
				break;
			}*/
		}
		else if(v==cb_pein_disease_other){
			cb_pein_disease_none.setChecked(false);
			if(cb_pein_disease_other.isChecked()){
				k++;
				et_pein_disease_other.requestFocus();
				et_pein_disease_other.setEnabled(true);
				if(!(tv_pein_disease_date1.getText().toString().length()>0)){
					tv_pein_disease_date1.setText("13");	
				}
				else if(!(tv_pein_disease_date2.getText().toString().length()>0)){
					tv_pein_disease_date2.setText("13");
				}
				else if(!(tv_pein_disease_date3.getText().toString().length()>0)){
					tv_pein_disease_date3.setText("13");
				}
				else if(!(tv_pein_disease_date4.getText().toString().length()>0)){
					tv_pein_disease_date4.setText("13");
				}
				else if(!(tv_pein_disease_date5.getText().toString().length()>0)){
					tv_pein_disease_date5.setText("13");
				}
				else if(!(tv_pein_disease_date6.getText().toString().length()>0)){
					tv_pein_disease_date6.setText("13");
				}   
			}
			else {
				k--;
				et_pein_disease_other.setEnabled(false);
				et_pein_disease_other.setText("");
				if(tv_pein_disease_date1.getText().toString()=="13"){
					tv_pein_disease_date1.setText("");
					et_pein_disease_year1.setText("");
					et_pein_disease_month1.setText("");
				}
				else if(tv_pein_disease_date2.getText().toString()=="13"){
					tv_pein_disease_date2.setText("");
					et_pein_disease_year2.setText("");
					et_pein_disease_month2.setText("");
				}
				else if(tv_pein_disease_date3.getText().toString()=="13"){
					tv_pein_disease_date3.setText("");
					et_pein_disease_year3.setText("");
					et_pein_disease_month3.setText("");
				}
				else if(tv_pein_disease_date4.getText().toString()=="13"){
					tv_pein_disease_date4.setText("");
					et_pein_disease_year4.setText("");
					et_pein_disease_month4.setText("");
				}
				else if(tv_pein_disease_date5.getText().toString()=="13"){
					tv_pein_disease_date5.setText("");
					et_pein_disease_year5.setText("");
					et_pein_disease_month5.setText("");
				}
				else if(tv_pein_disease_date6.getText().toString()=="13"){
					tv_pein_disease_date6.setText("");
					et_pein_disease_year6.setText("");
					et_pein_disease_month6.setText("");
				}	
			}
			if(k>6){
				Toast.makeText(getContext(), "您最多可选六项",Toast.LENGTH_SHORT).show();
				cb_pein_disease_other.setChecked(false);
				k--;
			}
	/*		for(int j=0;j<tv_pein_disease_date.length;j++){
				if(!tv_pein_disease_date[j].isEnabled()){
					tv_pein_disease_date[j].setText("13");
				}
				break;
			}*/
		}
		else if(v==rb_pein_nonesurgery){
			if(rb_pein_nonesurgery.isChecked()){
				et_pein_surgery_name1.setEnabled(false);
				et_pein_surgery_time1.setEnabled(false);
				et_pein_surgery_name2.setEnabled(false);
				et_pein_surgery_time2.setEnabled(false);
				et_pein_surgery_name1.setText("");
				et_pein_surgery_time1.setText("");
				et_pein_surgery_name2.setText("");
				et_pein_surgery_time2.setText("");
			}else{
				et_pein_surgery_name1.setEnabled(true);
				et_pein_surgery_time1.setEnabled(true);
				et_pein_surgery_name2.setEnabled(true);
				et_pein_surgery_time2.setEnabled(true);
			}
		}
		else if(v==rb_pein_surgery){
			et_pein_surgery_name1.requestFocus();
			et_pein_surgery_name1.setEnabled(true);
			et_pein_surgery_time1.setEnabled(true);
			et_pein_surgery_name2.setEnabled(true);
			et_pein_surgery_time2.setEnabled(true);
		}
		else if(v==rb_pein_nonetrauma){
			if(rb_pein_nonetrauma.isChecked()){
				et_pein_trauma_name1.setEnabled(false);
				et_pein_trauma_time1.setEnabled(false);
				et_pein_trauma_name2.setEnabled(false);
				et_pein_trauma_time2.setEnabled(false);
				et_pein_trauma_name1.setText("");
				et_pein_trauma_time1.setText("");
				et_pein_trauma_name2.setText("");
				et_pein_trauma_time2.setText("");
			}
		}
		else if(v==rb_pein_trauma){
			if(rb_pein_trauma.isChecked()){
				et_pein_trauma_name1.requestFocus();
				et_pein_trauma_name1.setEnabled(true);
				et_pein_trauma_time1.setEnabled(true);
				et_pein_trauma_name2.setEnabled(true);
				et_pein_trauma_time2.setEnabled(true);
			}
		}
		else if(v==rb_pein_nonetransfusion){
			if(rb_pein_nonetransfusion.isChecked()){
				et_pein_transfusion_reason1.setEnabled(false);
				et_pein_transfusion_time1.setEnabled(false);
				et_pein_transfusion_reason2.setEnabled(false);
				et_pein_transfusion_time2.setEnabled(false);
				et_pein_transfusion_reason1.setText("");
				et_pein_transfusion_time1.setText("");
				et_pein_transfusion_reason2.setText("");
				et_pein_transfusion_time2.setText("");
			}
		}
		else if(v==rb_pein_transfusion_reason){
			et_pein_transfusion_reason1.requestFocus();
			et_pein_transfusion_reason1.setEnabled(true);
			et_pein_transfusion_time1.setEnabled(true);
			et_pein_transfusion_reason2.setEnabled(true);
			et_pein_transfusion_time2.setEnabled(true);
		}
		else if(v==et_pein_surgery_time1){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_pein_surgery_time1), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_pein_surgery_time1.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_pein_surgery_time2){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_pein_surgery_time2), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_pein_surgery_time2.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_pein_trauma_time1){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_pein_trauma_time1), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_pein_trauma_time1.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_pein_trauma_time2){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_pein_trauma_time2), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_pein_trauma_time2.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_pein_transfusion_time1){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_pein_transfusion_time1), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_pein_transfusion_time1.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_pein_transfusion_time2){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_pein_transfusion_time2), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_pein_transfusion_time2.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
/*		else if(v==et_pein_disease_year1){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_pein_disease_year1), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_pein_disease_year1.setText(mPopupWindow.getYear());
					mPopupWindow.dismiss();
				}
				
			});
		}*/
    }
    /**
     * 系统自带的日期选择控件，因为自定义的需要3.0以上的版本
     * ！！仅当前测试使用！！
     * @param vdate 日期选择的触发控件
     */
    private void showDateDialog(EditText v) {
		// TODO Auto-generated method stub
    	Calendar cal = Calendar.getInstance();
    	int def_year = cal.get(Calendar.YEAR);
    	int def_month = cal.get(Calendar.MONTH);
    	int def_day = cal.get(Calendar.DAY_OF_MONTH);
    	final EditText vdate = v;
    	
    	new DatePickerDialog(myContext, 
    			new DatePickerDialog.OnDateSetListener() {
					
					@Override
					public void onDateSet(DatePicker view, int year, int monthOfYear,
							int dayOfMonth) {
						// TODO Auto-generated method stub
				    	Calendar c = Calendar.getInstance();
						c.set(Calendar.YEAR, year);
						c.set(Calendar.MONTH, monthOfYear);
						c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
						SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
						vdate.setText(sf.format(c.getTime()));
						System.out.println(vdate.getText().toString());
					}
				}, 
				def_year, def_month, def_day)//点击日期控件时默认显示当前日期
    	.show();
		
	}
}